module.exports = function (mongoose, Schema, ObjectId) {
  let accessSchema = new Schema({
    ip: {
      type: String,
      required: true
    },
    visitor: {
      type: ObjectId,
      ref: 'User'
    },
    blog: {
      type: ObjectId,
      ref: 'Blog',
      required: true
    },
    accessedAt: {
      type: Date,
      default: Date.now
    }
  })

  return mongoose.model('Access', accessSchema)
}
